<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

use App\Http\Controllers\General\CaptchaController;
use App\Http\Controllers\System\SystemConfigController;
use App\Http\Controllers\System\SystemLogController;
use App\Http\Controllers\System\SystemOperationLogController;
use App\Http\Controllers\General\File\LocalUploadController;
use App\Http\Controllers\General\File\OssController;
use App\Http\Controllers\General\SmsController;


//general
Route::middleware([])->prefix('general')->group(function (){
    //captcha
    Route::middleware(['throttle:captcha'])->post('captcha/calculate', [CaptchaController::class,'calculateCaptcha']);

    //sms
    Route::middleware(['throttle:sms.pm','throttle:sms.ph'])->prefix('sms')->controller(SmsController::class)->group(function (){
        //
        Route::post('register', 'sendRegisterSms');
        Route::post('login', 'sendLoginSms');
        Route::post('password/reset', 'sendPasswordResetSms');
    });


});

//system
Route::middleware(['strator.auth'])->prefix('system')->group(function (){
    //sytem log
    Route::post('log/list', [SystemLogController::class,'index']);
    //operation log
    Route::post('operation/log/list', [SystemOperationLogController::class,'index']);

    //config
    Route::prefix('config')->controller(SystemConfigController::class)->group(function (){
        //config
        Route::post('list', 'index');
        Route::post('set', 'setConfig');
        Route::post('get/by/key', 'getConfigByKey');
        Route::post('get/by/type', 'getConfigByType');
        Route::post('delete', 'destroyConfig');
    });


});

//upload
Route::middleware(['strator.auth'])->prefix('upload')->group(function (){
        //local
        Route::prefix('local')->controller(LocalUploadController::class)->group(function (){
            Route::post('image', 'imageUpload');
            Route::post('file', 'fileUpload');
        });
        //oss
        Route::prefix('oss')->controller(OssController::class)->group(function (){
            Route::post('image/server', 'uploadImageByServer');
            Route::post('file/server', 'uploadFileByServer');
            Route::post('image/direct/policy', 'directPolicyUploadImage');
            Route::post('file/direct/policy', 'directPolicyUploadFile');
        });


});
